<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
    String path = request.getContextPath(); 
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+path+ "/"; 
%>
<!DOCTYPE HTML>
<html>
<head>
	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<title>消息接收角色列表</title>
	<link rel="stylesheet" href="plugin/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/bootstrap-datetimepicker.css" />
    <link rel="stylesheet" href="plugin/bootstrap-table/dist/bootstrap-table.css">
<style type="text/css">

ul{
    list-style-type: none;
}
 .breadcrumb{
          padding: 21px 25px;
       }  
 a {
    color: #2a3f54;
}     
table{
   width:800px;
}   
td{
  width:400px;
}
</style>

</head>
<body>
<div class="row base-margin" id="query">
        <ul class="breadcrumb">
				<li style="padding-left: 15px"><i class="icon-home home-icon"></i> <a href="javascript:void(0)">System Settings(系统设置)</a>
				</li>
				<li class="active">
				<a href="view/sys/userInfo.jsp">User information(用户信息)</a></li>
        </ul>
    </div>
        <form class="form-horizontal"style="margin-left: 82px;" role="form"  method="post" id="queryForm">
		<table>
			<tr>
				<td>
					<div class="form-group">
						<label for="bName">Name(用户名):</label> <span style="margin-right: 60px">${user.name}</span>
					</div>
				</td>
				<td>
				   <div class="form-group">
						<label for="bName">Name(用户名):</label> <input type="text" id="userName1"
							value="${user.name}" />
					</div>
				</td>
			</tr>
			<tr>
			   <td><div class="form-group">
						<label for="bName">Gender(性别):</label> <span style="margin-right: 60px"
							id="sex">
							<c:if test="${user.sex==0}">
							male
							</c:if>
							<c:if test="${user.sex==1}">
							female
							</c:if>
							<c:if test="${user.sex==2}">
							other
							</c:if>
							</span> 
					</div>
				</td>
				  <td><div class="form-group">
						 <label for="bName">Gender(性别):</label> <input
							type="radio" id="sex0" name="sex" value="0"   style="margin-left:5px"
							<c:if test="${user.sex==0}">
							checked=checked
							</c:if>
							 /><span style="margin-left:5px">male</span><input
							type="radio" name="sex" id="sex1" value="1"style="margin-left:5px"
							<c:if test="${user.sex==1}">
							checked=checked
							</c:if>
							 /><span style="margin-left:5px">female</span><input type="radio" style="margin-left:5px"
							name="sex" id="sex" value="2" 
							<c:if test="${user.sex==2}">
							checked=checked
							</c:if>
							/><span style="margin-left:5px">other</span>
					</div>
				</td>
			</tr>
			<tr>
			   <td>
					<div class="form-group">
						<label for="bName">Id number(身份证号):</label> <span style="margin-right: 60px">${user.idcard}</span>
					</div>
				</td>
				<td>
					<div class="form-group">
						<label for="bName">Id number(身份证号):</label> <input type="text" id="cardId1"
							 value="${user.idcard}"/>
					</div>
				</td>
			</tr>
			<tr>
				<td><div class="form-group">
						<label for="bName">Email(邮箱):</label> <span style="margin-right: 60px">${user.mail}</span>
					</div>
				</td>
				<td><div class="form-group">
						<label for="bName">Email(邮箱):</label> <input type="text" id="email1"
							value="${user.mail}" />
					</div>
				</td>
			</tr>
		</table>
		<div class="form-group" style="margin-left:40px;margin-left: 200px; margin-top: 36px;">
                <button  onclick="save()" class="btn btn-info" style="width: 200px">Save</button>
            </div> 
        </form>
</body>
	<!-- 加载需要的js -->
	<script src="js/jquery-3.2.1.min.js"></script>
	<script src="plugin/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<script src="plugin/bootstrap-table/dist/bootstrap-table.min.js"></script>
	<script src="plugin/bootstrap-table/dist/locale/bootstrap-table-zh-CN.min.js"></script>
	
	<script src="js/common.js"></script>
	<script src="plugin/layer/layer.js"></script>
	<script type="text/javascript" charset="utf-8">
	function save(){
		var name=$('#userName1').val(); var idCard=$('#cardId1').val();var email=$('#email1').val();
		var sex= document.getElementsByName("sex"); var sex1=0;
		 for(var i=0;i<sex.length;i++) {
		 if(sex[i].checked){
			 var intHot = $(sex[i]).val();
			 sex1=intHot;
		 }
		 }
		 
		var data={"id":"${user.id}","name":name,"sex":sex1,"idcard":idCard,"mail":email};
		$.ajax({
			type:"post",
			url:"sysUser/updateUser",
			data: JSON.stringify(data),
	        contentType:"application/json;charset=UTF-8", 
	        dataType:"json",
	        async:false,
			success:function(data){
				if(data.code!=200){
					layer.msg(data.msg);
				}
			}
		});
	}
	</script>
</html>